package cn.basic.util;


import cn.basic.bean.bo.CommonBo;
import cn.basic.enums.ReturnCodeEnum;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 *  @author: zzz
 *  @date: 2020/5/18 11:16
 */
public class RespUtil {

    public static CommonBo queryNoResultResp(String callSn, String secretKey){
        CommonBo commonBo=new CommonBo(callSn,secretKey);
        commonBo.setCode(ReturnCodeEnum.QUERY_NO_RESULT.getCode());
        commonBo.setMessage(ReturnCodeEnum.QUERY_NO_RESULT.getMessage());
        commonBo.setResponseTime(getDateTime());
        return commonBo;
    }

    public static CommonBo commonResp(String code,String message,String callSn, String secretKey, Object resultData){
        CommonBo commonBo=new CommonBo(code,message,callSn,secretKey,resultData);
        commonBo.setResponseTime(getDateTime());
        return commonBo;
    }

    public static String getDateTime(){
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");
        String dateTime = LocalDateTime.now().format(formatter);
        return dateTime;
    }

}
